import 'package:custome_theme/theme_type.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'theme_provider.dart';
import 'home_page.dart';

void main() {
  runApp(
    ChangeNotifierProvider(
      create: (context) => ThemeProvider(),
      child: const MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Consumer<ThemeProvider>(
      builder: (context, provider, child) {
        // 获取当前主题（包含系统主题处理）
        final currentTheme = provider.themeType == ThemeType.system
            ? provider.getSystemTheme(context)
            : provider.currentTheme;

        return MaterialApp(
          title: '多主题UI组件示例',
          theme: currentTheme,
          darkTheme: provider.darkTheme,
          themeMode: provider.themeMode,
          home: const HomePage(),
        );
      },
    );
  }
}
